package sctu.edu.java.year2016.team03.maoyuhao.day20160605.chapter11_3;

/**
 *创建Computer类，该类中有个计算两个数的最大公约数的方法，如果想该方法传递负整数，该方法就会抛出自定义异常
 * Created by cc on 2016/6/7.
 */
public class Computer {
    public int Divide(int a, int b) throws MyException {
        if (a * b < 0) {
            Divide(a, b);

        }

        int value = 1;
        int max;
        int min;
        if (a == b) {
            return a;
        }
        if (a > b) {
            max = a;
            min = b;
        } else {
            max = b;
            min = a;
        }
        for (int i = 2; i < min; i++) {
            if (0 == max % i && 0 == min % i) {
                value = i;
            }
        }
        System.out.print(value);
        return value;
    }

    public static void main(String[] args) {
        Computer computer = new Computer();
        try {
            computer.Divide(2, 8);
        } catch (MyException e) {
            e.printStackTrace();
        }
    }
}
